package educationTool.model;

import educationTool.control.AdminController;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;

/**
 * JavaDoc, added by Pavel
 * An Admin singletone class for handling admin actions and logic
 * Default password is: admin
 * @author Boris
 */
public class Admin {
		
	private String password; 
        private static Admin INSTANCE;
        private Properties properties;
       
        private Admin()
        {
            FileInputStream fin;
            properties = new Properties();
            try {
                fin = new FileInputStream("admin.properties");
                properties.load(fin);
            }
            catch (IOException e) {
                throw new RuntimeException(e);
            }
            if (properties.getProperty("password") == null) {
                throw new RuntimeException("Properties file is empty!");
            }
            password =  properties.getProperty("password");
            
        }
        
        public static Admin getInstance() {
            if (INSTANCE == null) {
                INSTANCE = new Admin();
            }
            return INSTANCE;
        }
        
	
        
	public void setPassword(final String password) {
            this.password = password;
        }
        
	public String getPassword() {
		return password;
	}
        
}
